/*
 * Copyright (c) 2010 Marc Poppleton
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.marcpoppleton.strawberry;

import java.util.HashMap;
import java.util.List;

import org.marcpoppleton.strawberry.provider.HelpProvider;

import android.app.ExpandableListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ExpandableListAdapter;
import android.widget.SimpleExpandableListAdapter;


public class HelpActivity extends ExpandableListActivity{
    
    static void show(Context context) {
        final Intent intent = new Intent(context, HelpActivity.class);
        context.startActivity(intent);
    }
	
    private ExpandableListAdapter mAdapter;
    
    @SuppressWarnings("unchecked")
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        HashMap<String,List>help = HelpProvider.getHelp(this, R.xml.help);
        
        // Set up our adapter
        mAdapter = new SimpleExpandableListAdapter(
                this,
                help.get(HelpProvider.TITLE),
                R.layout.help_title,
                new String[] { HelpProvider.TITLE},
                new int[] { android.R.id.text1},
                help.get(HelpProvider.HELP),
                R.layout.help_content,
                new String[] { HelpProvider.HELP},
                new int[] { android.R.id.text1}
                );
        setListAdapter(mAdapter);
    }

}
